package com.jt.serviceImpl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jt.mapper.UserMapper;
import com.jt.pojo.User;
import com.jt.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import redis.clients.jedis.JedisCluster;

import java.util.HashMap;
import java.util.Map;

/**
 * @author dc
 */
@Service
public class UserServiceImpl implements UserService {
	
	@Autowired
	private UserMapper userMapper;

	@Autowired
	private JedisCluster redis;

	private final Map<Integer,String> map = new HashMap<>();

	@Override
	public boolean checkUser(String param, Integer type) {
		map.put(1,"username");
		map.put(2,"phone");
		map.put(3,"email");
		String column = map.get(type);
		QueryWrapper queryMapper=new QueryWrapper();
		queryMapper.eq(column,param);
		User user =(User) userMapper.selectOne(queryMapper);
		return user==null?false:true;
	}

	@Override
	public String findUserByTicket(String ticket) {
		String userJson = redis.get(ticket);
		return userJson;
	}
}
